package com.mdp.workflow.idm;

import com.mdp.core.entity.Result;
import com.mdp.safe.client.entity.User;
import com.mdp.safe.client.utils.LoginUtils;
import com.mdp.workflow.pub.service.SysUserService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * url编制采用rest风格,如对WF.act_ru_task的操作有增删改查,对应的url分别为:<br>
 *  新增: workflow/ru/task/add <br>
 *  查询: workflow/ru/task/list<br>
 *  模糊查询: workflow/ru/task/listKey<br>
 *  修改: workflow/ru/task/edit <br>
 *  删除: workflow/ru/task/del<br>
 *  批量删除: workflow/ru/task/batchDel<br>
 * 组织 com.qqkj  顶级模块 mdp 大模块 workflow 小模块 ru<br>
 * 实体 Task 表 WF.act_ru_task 当前主键(包括多主键): id_; 
 ***/
@RestController("mdp.workflow.idm.user") 
public class WorkflowUserController {
	
	static Log logger=LogFactory.getLog(WorkflowUserController.class);
	
	@Autowired
	SysUserService sysUserService;
		 
	 
	  @RequestMapping(value = "/**/rest/workflow-users", params= {"filter"}, method = RequestMethod.GET, produces = "application/json")
	public Result workflowUsersFilter(String filter){
		 
		User u=LoginUtils.getCurrentUserInfo();
		
		List<Map<String,Object>> users= sysUserService.selectMdpUsersByFilter(u.getBranchId(),filter);
		
		//m.put("data",users);
		
		 
		return Result.ok().setData(users);
	}
	  @RequestMapping(value = "/**/rest/workflow-groups", params= {"filter"}, method = RequestMethod.GET, produces = "application/json")
	public Result workflowGroupsFilter(String filter){
		 
		User u=LoginUtils.getCurrentUserInfo();
		
		List<Map<String,Object>> groups= sysUserService.selectMdpGroupsByFilter(u.getBranchId(),filter);
		
		//m.put("data",groups);
		
		 
		return Result.ok().setData(groups);
	}
}
